const Controller = require('egg').Controller;

class UserController extends Controller {
 // 添加学生信息
 async addUser() {
  const { ctx } = this;
  const { name, age } = ctx.request.body;
  const result = await ctx.service.user.addUser(name, age);
  if (result) {
     ctx.body = {
       status: 200,
       msg: '添加成功',
       data: {},
     };
 } else {
     ctx.body = {
       status: 201,
       msg: '添加失败',
       data: {},
   };
 }
}
 // 删除学生信息
 async delStu() {
    const { ctx } = this;
    ctx.body = {
      status: 200,
      msg: '删除成功',
      data: {},
    };
  }
 // 更新学生信息
 async updateStu() {
    const { ctx } = this;
    ctx.body = {
       status: 200,
       msg: '更新成功',
       data: {},
    };
  }
 // 查询学生信息
 async getUser() {
     const { ctx } = this;
     const result = await ctx.service.user.getUser();

     if (result) {
      ctx.body = {
        status: 200,
        msg: '查询成功',
        data: result,
      };
  } else {
      ctx.body = {
        status: 201,
        msg: '查询失败',
        data: {},
    };
  }
  }
}
module.exports = UserController;